<template>
  <div class="p-4 bg-light mb-3">
    <span>课程等级:</span>
    <router-link :to="{name:'course',query:{curPage:1,typeId:0}}" :class=" typeId == 0 ? 'btn btn-success ml-3':'btn ml-3'">全部课程</router-link>
    <router-link v-for="(item,index) in list" :key="index" :to="{name:'course',query:{curPage:1,typeId:item.tpid}}" :class=" typeId == item.tpid ? 'btn btn-success ml-3':'btn ml-3'">{{item.tpname}}</router-link>
  </div>
</template>

<script>

export default {
  name:"TypeNav",
  data() {
    return {
      list:[],
      typeId:"",
      courseType:["全部课程","基础课程","核心课程","进阶课程"]
    }
  },
  methods: {
    getTypes(){
      this.axios
        .get("/type", {
          params: {
            // pageNum:this.$route.query.curPage
            curPage: this.curPage
          }
        })
        .then(res => {

          if (res.data.code == 200) {
            this.list = res.data.data;

          }
        })
        .catch(err => {
          console.error(err);
        });
    }
  },
  mounted() {
   
    this.getTypes();
    this.typeId=this.$route.query.typeId;

  },
}

</script>
<style scoped>
</style>